<template>
  <div class="merchant alltable">
    <div class="tabbar">
      <div class="let">
        <DatePicker
          type="date"
          placement="bottom-end"
          v-model="data_axios.startday"
          value = 'yyyy-MM-dd'
          placeholder="请选择开始日期"  
          style="width: 130px"
        ></DatePicker>&nbsp;
        <DatePicker
          type="date"
          placement="bottom-end"
          v-model="data_axios.endday"
          placeholder="请选择结束日期"
          style="width: 130px"
        ></DatePicker>&nbsp;        
        <Input
          prefix="ios-search"          
          v-model.trim="data_axios.selectinfo"
          placeholder="请输入关键字"
          style="width: 200px"
        />
        <Button class="btn_default" @click="search">
          <Icon type="ios-search" size="17" class="icon_wy"/>查询
        </Button>
      </div>
        <div class='rit'>              
            <!-- <Button @click="model2=true" ><Icon type="ios-add-circle-outline" size="17" class="icon_wy"/>添加结算单</Button> -->
      </div>
    </div>
    <div class="tabble">
      <div>
        <Table
          :columns="columns"
          :loading="loading"
          height="560"
          :data="data.datas"
          class="sel_table"
        ></Table>
      </div>
    </div>

    <div class="tab_pages">
      <Page
        :total="data.allCount"
        :page-size="data_axios.pagesize"
        :current.sync="data_axios.pagenumber"
        show-total
        @on-change="merchant_data"
      >
      </Page>
    </div>
    
  </div>
</template>
<script>
import { setAdmin, setToken, getAdmin } from "../../../utils/auth.js";
import { selectSettleDetList} from "../../../apis/api_system.js";
import filter from './../../../filters/filter';
// import { validatePhone ,validateIdnumber} from "../../../utils/validate.js";
export default {
  name: "bus_listing",
  data() {
    return {
      indeterminate: true,
      checkAll: false,
      checkAllGroup: ['香蕉', '西瓜'],
      userId: "",      
      model2: false,
      fix_modal_loading:false,
      add_modal_loading:false,
      value: "",
      userName:"",
      options3: {
          disabledDate (date) {
              return date && date.valueOf() > Date.now()-86400000;
          }
      },
      options4: {
          disabledDate (date) {
              return date && date.valueOf() > Date.now()-86400000;
          }
      },
      data: {
        allCount: 0,
        currPage: 1,
        datas: [],        
      },
      data_axios: {
        startday:"",
        endday: "",
        pagesize: 10,
        pagenumber: 1,        
        selectinfo: "",        
      },
      fix_data:{
      },
      add_data:{
        midlist: [],
        startday:"",
        endday:"",
      },
      loading: false,
      Mnamelist: [],
      
      columns: [
        {
          title: "序号",
          key: "name",
          type: "index",
          width: 50
        },
        {
          title: "商户名",
          key: "cname"
        },
        {
          title: "商户号",
          key: "mid",
        //    width: 100
        },
        {
          title: "经营者名字",
          key: "mname"
        },
        {
          title: "结算日期",
          key: "createdate",
        //   width: 100
        },
         {
          title: "支付金额",
          key: "paymentamt",
        //   width: 100
        },
         {
          title: "费率",
          key: "rate",
        //   width: 100
        },
        {
          title: "手续费 ",
          key: "poundage",
        //   ,
        //   width: 100
        },        
        
        {
          title: "结算金额 ",
          key: "settleamt",
        //    width: 200
        },
        {
          title: "结算条数 ",
          key: "settlecount",
            // width: 150
        },
        {
          title: "结算单号 ",
          key: "settleid",
            // width: 150
        },
        {
          title: "时间",
          key: "startday",
          render: (h, params) => {
            const row = params.row;
            // 1已完成 2已退款
            const text = row.startday+'至'+ row.endday;
            return <span>{text}</span>;
          }
        },       
        
        // {
        //   title: "操作",
        //   key: "",
         
        //   render: (h, params) => {
        //     let self = this;
        //     return (
        //       <div class="lastcoll">
        //       <i
        //           on-click={() => self.to_detail(params)}
        //           class="ivu-icon ivu-icon-ios-paper-outline icon_weight"
        //           title="详情"
        //         >
        //           详情
        //         </i>
               
                
        //       </div>
        //        // <i
        //         //   on-click={() => self.setmodal_edit(params)}
        //         //   class="ivu-icon ivu-icon-ios-create-outline icon_weight"
        //         //   title="修改"
        //         // >
        //         //   修改
        //         // </i>
        //     //   <i
        //     //       on-click={() => self.del(params)}
        //     //       class="ivu-icon ivu-icon-ios-trash-outline icon_weight"
        //     //       title="删除"
        //     //     >
        //     //       删除
        //     //     </i>
        //     );
        //   }
        // }
      ],
      
    };
  },
  
  mounted() {    
    let info = getAdmin();   
    this.userId = info.id;
    this.userName = info.name;        
    this.selectSettleDetList(this.data_axios);    
  },
  methods: {    
    
    //   获取结算单列表详情
    selectSettleDetList(info) {     
        this.loading = true; 
       if(this.data_axios.startday!=''){
          this.data_axios.startday =  filter.FileterDate(this.data_axios.startday);
       }
       if(this.data_axios.endday!=''){
          this.data_axios.endday =  filter.FileterDate(this.data_axios.endday);
       }      
      let data = JSON.stringify({
        requestString: JSON.stringify(info),
        userId: this.userId,
        fullname: "结算单列表详情"
      });     
      selectSettleDetList(data).then(({ returnString, code, disp ,count}) => { 
          this.loading = false;
          if (code == 200) {    
           
            this.data.datas = JSON.parse(returnString);
            this.data.allCount = count;            
          } else {            
            this.$Message.warning(disp);
          }
        })
        .catch(err => {
            this.$Message.warning('请求出错');
        });
    },
    
   
    //分页改变
    merchant_data() {
       this.selectSettleDetList(this.data_axios);
    },
    search(){
      this.data_axios.pagenumber=1;
      this.selectSettleDetList(this.data_axios);
    },
    
  }
};
</script>
<style scoped=true>
  .ivu-checkbox-group{
    display: inline-block;
  }
</style>